;(function () {
    var options = {};
    $(function () {
        initEvent();
    });
    function initEvent() {
        getRadarOne();
        getRadarTwo();
        showRadar();
        getPie();
        getBar();
    }

    function showRadar() {
        option = {
            radar: [{
                indicator: [{
                    name: '服务态度',
                    max: 100
                }, {
                    name: '企业业绩',
                    max: 100,
                    axisLabel: {
                        show: false
                    }
                }, {
                    name: '资质情况',
                    max: 100,
                    axisLabel: {
                        show: false
                    }
                }, {
                    name: '信用评价',
                    max: 100,
                    axisLabel: {
                        show: false
                    }
                }, {
                    name: '质量评价',
                    max: 100,
                    axisLabel: {
                        show: false
                    }
                }],
                center: ['50%', '60%'],
                radius: '60%',
                // startAngle: 90,
                splitNumber: 5,
                shape: 'polygon',
                triggerEvent: true,
                silent: true,
                scale: true,
                // nameGap:2,
                name: {
                    formatter: '{value}',
                    textStyle: {
                        color: '#333',
                        fontSize: 16
                    }
                },
                splitArea: {
                    show: false
                },
                axisLine: {
                    lineStyle: {
                        color: '#e6e6e6'
                    }
                },
                axisTick: {
                    show: true
                },
                axisLabel: {
                    show: true,
                    color: '#9e9e9e'
                },
                splitLine: {
                    lineStyle: {
                        color: '#e6e6e6'
                    }
                }
            }],
            series: [{
                name: '雷达图',
                type: 'radar',
                areaStyle: {
                    normal: {
                        color: 'rgba(23,139,246,0.7)'
                    }
                },
                lineStyle: {
                    normal: {
                        color: '#178bf6',
                        width: 2
                    }
                },
                data: [{
                    value: [70, 60, 40, 50, 60],
                    symbol: 'circle',
                    symbolSize: 6,
                    itemStyle: {
                        normal: {
                            color: '#178bf6'
                        }
                    }
                }]
            }]
        }
    }

    function getRadarOne(){
        showRadar();
        var myChart1 = echarts.init(document.getElementById("leiD1"));
        myChart1.setOption(option)
    }

    function getRadarTwo(){
        showRadar();
        var myChart2 = echarts.init(document.getElementById("leiD2"));
        myChart2.setOption(option)
    }

    function getPie() {
        var uploadedDataURL = "/webstie/assets/images/centerPie.png";

        var colorList = ['#F04864', '#216DE5'];
        var sportsIcon = {
            'a': "/webstie/assets/images/centerPie.png",
        };
        option = {
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                // orient: 'vertical',
                x: 'center',
                y:'bottom',
                data: ['男', '女'],
                icon:'circle',
                itemGap: 20,
                textStyle:{
                    padding:[2,0,0,0]
                }
            },
            grid: {
                top:30,
                bottom: 30,
                left:100,
                right: 100
            },
            series: [
                // 主要展示层的
                {
                    name: '男女比例分析',
                    radius: '50%',
                    center: ['50%', '50%'],
                    type: 'pie',
                    itemStyle: {
                        normal: {
                            color: function(params) {
                                return colorList[params.dataIndex]
                            }
                        }
                    },
                    labelLine: {
                        normal: {
                            show: true,
                            length: 25,
                            length2: 0,
                            lineStyle: {
                                // color: '#f00'
                            },
                            align: 'right'
                        },
                        color: "#1890ff",
                        emphasis: {
                            show: true
                        }
                    },
                    label: {
                        normal: {
                            formatter: function(params) {
                                var str = '';
                                switch (params.name) {
                                    case '男':
                                        str = '{a|}\n{nameStyle|男 }';
                                        break;
                                    case '女':
                                        str = '{b|}\n{nameStyle|女 }';
                                        break;

                                }
                                return str
                            },
                            rich: {
                                a: {
                                    width: 30,
                                    height: 30,
                                    lineHeight: 40,
                                    backgroundColor: {
                                        image: sportsIcon.a
                                    },
                                    align: 'center',
                                },
                                b: {
                                    width: 30,
                                    height: 30,
                                    lineHeight: 40,
                                    backgroundColor: {
                                        image: sportsIcon.a
                                    },
                                    align: 'center',
                                },
                                nameStyle:{
                                    color:'#1890ff',
                                    align: 'center',
                                    padding:[0,0,0,5]
                                }
                            }
                        }
                    },
                    data: [{
                        value: 17,
                        name: '男',
                    },
                        {
                            value: 23,
                            name: '女'
                        }
                    ],
                },

            ]
        };

        var myChart3 = echarts.init(document.getElementById("chears1"));
        myChart3.setOption(option)
    }

    function getBar() {
        option = {
            color: ['#3AA1FF'],
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                },
                formatter: "{b}  : {c}人"
            },
            grid: {
                left: '5%',
                right: '5%',
                bottom: '2%',
                containLabel: true
            },
            xAxis: {
                type: 'value',
                // boundaryGap: [0, 0.0001],
                axisLabel: {
                    formatter: '{value}',
                    textStyle: {
                        color: '#9E9E9E',
                        fontWeight: '80'
                    }
                },
                axisLine:{
                    show:false
                },
                axisTick:{
                    show:false
                },
                splitLine:{
                    show: true,
                    // interval: 'auto',
                    lineStyle:{
                        color: ['#eee'],
                        width: 1,
                        type:'dashed'
                    }
                }
            },
            yAxis: {
                type: 'category',
                data: ['二级建造师', '一级建造师', '二级建筑师', '造价工程师', '监理工程师', '一级结构师', '化工工程师', '电器工程师', '土木工程师'],
                axisLabel: {
                    show: true,
                    rotate: 0,
                    margin: 10,
                    inside: false,
                    textStyle: {
                        color: '#9E9E9E',
                        fontWeight: '50'
                    }
                },
                axisLine:{
                    show:false
                },
                axisTick:{
                    show:false
                },
            },
            series: [{
                type: 'bar',
                barMaxWidth:25,
                label: {
                    normal: {
                        show: true,
                        position:'right',
                        formatter: function(v) {
                            var val = v.data;
                            if (val == 0) {
                                return '';
                            }
                            return val;
                        },
                        color: '#9E9E9E'
                    }
                },
                data: [122, 133, 441, 515, 661, 771, 818,1122,1122]
            }]
        };
        var myChart1 = echarts.init(document.getElementById("chears2"));
        myChart1.setOption(option)
    }

})(jQuery);